package app.dao;

import app.domain.User;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface DaoUser extends JpaRepository<User, Integer> {
    //登录方法
    User getByUsername(String username);

    //修改方法
    @Transactional
    @Modifying
    @Query("update User an set an.username=?2,an.password=?3 where an.id=?1")
    int update(Integer id, String username, String password);
}
